<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>费用设置 - TMS</title>
    <link rel="stylesheet" href="/view/frame/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/view/frame/static/css/global.css?v=1.0">
    <link rel="stylesheet" href="/view/tms/static/css/iframe.css?v=1.0">
  </head>
  <body>
    <!--start: 搜索-->
    <div class="panel-handle search-bar">
      <form class="layui-form layui-form-pane">
        <!-- <button class="layui-btn layui-btn-danger" onclick="window.location.href='list.html'">全部</button> -->
        <div class="layui-input-inline">
          <label class="layui-form-label">费用名称</label>
          <div class="layui-input-inline">
            <input type="text" name="costName"  autocomplete="off" class="layui-input">
          </div>
        </div>
        <div class="layui-inline">
          <label class="layui-form-label">费用类型</label>
          <div class="layui-input-inline">
            <select name="costType">
            <option value="" selected="selected">全部</option>
            </select>
          </div>
        </div>
         <div class="layui-inline">
          <label class="layui-form-label">状态</label>
          <div class="layui-input-inline">
            <select name="status">
            <option value="" selected="selected">全部</option>
            </select>
          </div>
        </div>
        <button class="layui-btn layui-btn-danger" lay-submit lay-filter="search"><i class="layui-icon">&#xe615;</i>查询</button>
      </form>
    </div>
    <!--end: 搜索-->
  
    <!--start:表格列表-->
    <table class="layui-hide" id="tableList" lay-filter="tbar"></table>
    <!--end:表格列表-->


  </body>
  <script charset="utf-8" src="/view/frame/static/js/jquery.min.js?v=1.0"></script>
  <script charset="utf-8" src="/view/frame/layui/layui.js"></script>
  <!-- <script charset="utf-8" src="?v=1.0"></script> -->
  <script charset="utf-8" src="/view/tms/static/js/tms_index.js?v=1219"></script>
  
  <script charset="utf-8" src="/view/frame/static/js/errorCodeMap.js"></script>
  <script charset="utf-8" src="/view/frame/static/js/HC.js?v=1.4"></script>
  <script charset="utf-8" src="/view/tms/static/js/validator.js"></script>
  <script charset="utf-8" src="/view/tms/static/js/bizUtil.js"></script>
  
  <script>
  layui.use(['form', 'layer', 'table', 'tms_tab'], function(){
    var form = layui.form,
        layer = layui.layer,
        table = layui.table,
        tmsTab = layui.tms_tab,
        $ = layui.jquery;

    setTableData();

    //子系统接口
    $.get('/ucenter/code/common/system/search.shtml', function(d){
      var $code = d.code,
          $msg = d.msg,
          $objects = d.objects;

      if($code != 'SUCCESS') return false;
      
      if($objects.length > 0){
        for(var $i = 0; $i < $objects.length; $i++){
          $('select[name="platformId"]').append('<option value="'+ $objects[$i].id +'">'+ $objects[$i].name +'</option>');
        }
        form.render('select');
      }
    }, 'json');
    
    //监听提交
    form.on('submit(search)', function(data){
      var $costName = $.trim(data.field.costName),
      $costType = $.trim(data.field.costType);
      $search = $.trim(data.field.search);
      setTableData($costName, $costType, $search);
      console.log($costName, $costType, $search);
      return false;
    });
    
    //方法级渲染
    function setTableData($costName, $costType, $search){
      typeof $costName != 'undefined' ? $costName = $costName : $costName = '';
      typeof $costType != 'undefined' ? $costType = $costType : $costType = '';
      typeof $search != 'undefined' ? $search = $search : $search = '';
      var $pageSize = 15;

      table.render({
        elem: '#tableList',
        url: '',
        response: {
          statusCode: 'SUCCESS',
          countName: 'objects.total', //数据总数的字段名称，默认：count
          dataName: 'objects.list'
        },
        request: {
          pageName: 'pageNum', //页码的参数名称，默认：page
          limitName: 'pageSize' //每页数据量的参数名，默认：limit
        },
        cols: [[
          {field:'id', title: '费用名称', width:100, align: 'center'},
          {field:'name', title: '费用编码', width:100, align: 'center'},
          {field:'platformName', title: '费用类型', width:100, align: 'center'},
          {field:'remarks', title: '是否交税', width:100, align: 'center'},
          {field:'roleUsers', title: '会计科目', width:100, align: 'center'},
           {field:'name', title: '状态', width:150, align: 'center'},
          {align:'center', title: '创建时间', toolbar: '#toolBar', width:200}
        ]],
        id: 'dataReload',
        page: true,
        limits: [15, 30, 50, 100],
        limit: $pageSize,
        height: 'full-130',
        even: true,
        done: function(res, curr, count){}
      });
    }
  });
  </script>
</html>